<!--
 * @Author: xuwejie 1529315455@qq.com
 * @Date: 2023-08-29 13:58:24
 * @LastEditors: xuwejie 1529315455@qq.com
 * @LastEditTime: 2023-08-29 14:02:43
 * @FilePath: \cdj-jyt_school-vue\src\views\configuration\index2.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="首页通知" prop="name">
        <el-input
          type="textarea"
          :rows="2"
          placeholder="请输入首页通知"
          v-model="ruleForm.content"
        >
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="submit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import { partnerNotice_index, partnerNotice_save } from "@/api/shop/shop";
export default {
  data() {
    return {
      ruleForm: {
        content: null,
      },
    };
  },
  created() {
    this.getContent();
  },
  methods: {
    getContent() {
      let data = Object.assign(
        { type: 5 },
        apiUrl().name
      );
      partnerNotice_index(data).then((res) => {
        if (res.errcode == 0) {
          this.ruleForm.content = res.data.content;
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    submit() {
      let data = Object.assign(
        { type: 5, content: this.ruleForm.content },
        apiUrl().name
      );
      partnerNotice_save(data).then((res) => {
        if (res.errcode == 0) {
          this.$message.success("保存成功");
          this.getContent();
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
  },
};
</script>